package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.GraySwitchInfoMapper;
import com.xyy.saas.payment.dao.model.GraySwitchInfo;
import com.xyy.saas.payment.service.GraySwitchInfoService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

public class GraySwitchInfoServiceImpl implements GraySwitchInfoService {

    @Autowired
    private GraySwitchInfoMapper graySwitchInfoMapper;

    @Override
    public List<GraySwitchInfo> batchInsert(List<GraySwitchInfo> entity) {
        if(entity.isEmpty()) {
            return new ArrayList<>();
        }
        List<GraySwitchInfo> result = new ArrayList<>();
        for (GraySwitchInfo graySwitchInfo : entity) {
            int rows = graySwitchInfoMapper.insert(graySwitchInfo);
            if(rows > 0) {
                result.add(graySwitchInfo);
            }
        }
        return result;
    }

    @Override
    public List<GraySwitchInfo> queryByParam(GraySwitchInfo queryParam) {
        return graySwitchInfoMapper.queryByParam(queryParam);
    }

    @Override
    public GraySwitchInfo queryById(Long id) {
        return graySwitchInfoMapper.queryById(id);
    }

    @Override
    public int deleteById(String id) {
        return graySwitchInfoMapper.deleteById(id);
    }

    @Override
    public int batchDelete(List<String> ids) {
        int rows = 0;
        for (String id : ids) {
            rows += graySwitchInfoMapper.deleteById(id);
        }
        return rows;
    }
}
